package model.lights;

import java.awt.Color;

import javax.vecmath.Point3d;


public abstract class Light {
	public Color diffuseColor;
	public Color ambientColor;
	public float power;
	public Point3d source;
	public Light[] gridLight;
	public boolean isGrid;
	
	public void setdiffuseColor(Color color) {
		this.diffuseColor = color;
	}

	public void setAmbientColor(Color ambientColor) {
		this.ambientColor = ambientColor;
	}

	public void setPower(float power) {
		this.power = power;
	}

	public void setSource(Point3d source) {
		this.source = source;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((ambientColor == null) ? 0 : ambientColor.hashCode());
		result = prime * result
				+ ((diffuseColor == null) ? 0 : diffuseColor.hashCode());
		result = prime * result + Float.floatToIntBits(power);
		result = prime * result + ((source == null) ? 0 : source.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Light other = (Light) obj;
		if (ambientColor == null) {
			if (other.ambientColor != null)
				return false;
		} else if (!ambientColor.equals(other.ambientColor))
			return false;
		if (diffuseColor == null) {
			if (other.diffuseColor != null)
				return false;
		} else if (!diffuseColor.equals(other.diffuseColor))
			return false;
		if (Float.floatToIntBits(power) != Float.floatToIntBits(other.power))
			return false;
		if (source == null) {
			if (other.source != null)
				return false;
		} else if (!source.equals(other.source))
			return false;
		return true;
	}
	
	public abstract float getAttenuation(double distance);	
		
}
